import store from '@/store'

/**
 * 权限
 * @param {*} key
 */
export default {
	install(Vue, options) {
		// 权限验证，返回true有权限 false没有权限
		Vue.prototype.$hasPermission = key => {
			const permissions = store.getters.permission.permissions
			return permissions && permissions.includes(key)
		}
		// 批量权限验证，返回有权限的个数
		Vue.prototype.$hasPermissionNum = keys => {
			const permissions = store.getters.permission.permissions;
			let Num = 0;
			for (var i = 0; i < keys.length; i++) {
				if(keys[i] && permissions && permissions.includes(keys[i])){
					Num+=1;
				}
			}
			return Num
		}
	}
}